package com.itfreer.gis.data.server.arcgis;

import com.itfreer.gis.data.server.GlobalDataType;

/**
 * 类功能说明 定义结构表类型转换为Oracle数据库类型
 */
public class ArcgisDataTypeConvert {

	/**
	 * @Title: Convert
	 * @Description: 结构表数据类型转换
	 * @param @param dateType
	 * @param @return
	 * @throws
	 */
	public String Convert(GlobalDataType dateType) {
		String oracleType = "";
		switch (dateType) {
		case Boolean:
			oracleType = "esriFieldTypeBoolean";
			break;
		case Char:
			oracleType = "esriFieldTypeChar";
			break;
		case String:
			oracleType = "esriFieldTypeString";
			break;
		case Text:
			oracleType = "NCLOB";
			break;
		case Date:
		case DateTime:
			oracleType = "esriFieldTypeDate";
			break;
		case Decimal:
			oracleType = "esriFieldTypeDouble";
			break;
		case Double:
			oracleType = "esriFieldTypeDouble";
			break;
		case Single:
			oracleType = "REAL";
			break;
		case UInt:
		case Int:
			oracleType = "esriFieldTypeInteger";
			break;
		case ByteArray:
			oracleType = "BLOB";
			break;
		case NoDefault:
			break;
		default:
			break;
		}
		return oracleType;
	}

	public GlobalDataType Convert(String dateType) {
		GlobalDataType gType = GlobalDataType.NoDefault;
		dateType = dateType.toUpperCase();
		if ("esriFieldTypeBoolean".equals(dateType)) {
			gType = GlobalDataType.Boolean;
		} else if ("esriFieldTypeChar".equals(dateType)) {
			gType = GlobalDataType.Char;
		} else if ("esriFieldTypeString".equals(dateType)) {
			gType = GlobalDataType.String;
		} else if ("NCLOB".equals(dateType)) {
			gType = GlobalDataType.Text;
		} else if ("esriFieldTypeDate".equals(dateType)) {
			gType = GlobalDataType.DateTime;
		} else if ("esriFieldTypeDouble".equals(dateType)) {
			gType = GlobalDataType.Double;
		} else if ("REAL".equals(dateType)) {
			gType = GlobalDataType.Single;
		} else if ("esriFieldTypeInteger".equals(dateType)) {
			gType = GlobalDataType.Int;
		} else if ("LONG RAW".equals(dateType) || "BLOB".equals(dateType)) {
			gType = GlobalDataType.ByteArray;
		}
		return gType;
	}
}
